package design.patterns.observer.advanceobserver.exercise;

import java.util.ArrayList;
import java.util.List;

/**
 * desc : 抽象主题角色
 * time : 2020-07-21 18:42
 *
 * @author wwchen
 */
abstract class Subject {
    private List<Observer> observerList = new ArrayList<>();
    public void addObserver(Observer o){
        observerList.add(o);
    }

    public void deleteObserver(Observer o){
        observerList.remove(o);
    }

    public List<Observer> getObserverList(){
        return observerList;
    }
    public void notifyAllObserver(){
        for (Observer observer : observerList) {
            observer.update();
        }
    }
}
